package com.niit.lcy.areaselref;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author: Chase
 * @Date: 2024/12/10
 */

public class AreaSelRefPartitioner extends Partitioner<Text, Text> {

    /**
     * 自定义分区
     *
     * @param text01
     * @param text02
     * @param i
     * @return 0 - 60㎡  -> 0
     * 61 - 90㎡  -> 1
     * 91 - 120㎡  -> 2
     * 121㎡  - 150㎡  -> 3
     * 151㎡  - 190㎡  -> 4
     * > 190㎡  -> 5
     */
    @Override
    public int getPartition(Text text01, Text text02, int i) {
        String scope = text01.toString();
        if (scope.equals("大于190㎡")) {
            return 5;
        } else if (scope.equals("151-190㎡")) {
            return 4;
        } else if (scope.equals("121-150㎡")) {
            return 3;
        } else if (scope.equals("91-120㎡")) {
            return 2;
        } else if (scope.equals("61-90㎡")) {
            return 1;
        } else if (scope.equals("0-60㎡")) {
            return 0;
        }
        return 0;
    }
}
